<template>
  <div class="scenic border-bottom" >
    <ul>
      <swiper :options="swiperOption" ref="mySwiper">
        <swiper-slide v-for="(pages,index) of page" :key="index">
          <li v-for="item of pages" :key="item.id">
            <img :src="item.imgUrl">
            <p>{{item.name}}</p>
          </li>
        </swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'HomeScenic',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        }
      }
    }
  },
  computed: {
    page () {
      let arr = []
      this.list.forEach((obj, index) => {
        let pages = Math.floor(index / 8)
        if (!arr[pages]) {
          arr[pages] = []
        }
        arr[pages].push(obj)
      })
      return arr
    }
  }
}
</script>

<style lang="stylus" scoped="scoped">
  .scenic >>> .swiper-container
    height 0
    padding-bottom 50%
  .scenic
    overflow hidden
    height 3.8rem
    background white
  .scenic
    ul
      li
        width 25%
        float left
        text-align center
        padding-top 0.1rem
  .scenic
    ul
      li
        img
          width: 1.1rem
          height: 1.1rem
  .scenic
    ul
      li
        p
          margin-top 0.1rem
</style>
